class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        re = set()
        re1 =set()
        max = 0
        for i in range(len(s)):
            l = r = i
            while r<len(s):
                re.add(s[r])
                if len(re) == len(s[l:r+1]):
                    max = len(s[l:r + 1])
                    re1.add(max)
                else:
                    re.clear()
                    break
                r = r + 1
            re.clear()

        for i in re1:
            if i > max:
                max = i

        return max


if __name__ == "__main__":
    s = "bbbbb"
    a = Solution()
    b = a.lengthOfLongestSubstring(s)
    print(b)
